<?php
namespace wow\model\tools;
/**
 * Checks if a connection is up based on ip / port.
 * 
 * @author peec
 *
 */
class ServiceTool{
	
	private $ip = '';
	private $port = 80;
	private $timeout = 2;
	
	
	public function __construct($ip, $port, $timeout = 2){
		$this->ip = $ip;
		$this->port = $port;
		$this->timeout = $timeout;
	}
	
	/**
	 * Checks if a connection is up.
	 */
	public function isUp(){
		$o = \gnomephp\Configuration::get('site','localip_override');
		return @fsockopen($o ? $o : $this->ip, $this->port, $errno, $errstr, 2);
	}

}